import request from '@/utils/request.js';

//注册
export const registerService = (registerData) => {
    var params = new URLSearchParams()
    for (let key in registerData) {
        params.append(key, registerData[key])
    }
    return request.post('/user/register', params)
}

export const userLoginService =(logindata)=>{
    const params =new URLSearchParams();
    for (let key in logindata){
        params.append(key,logindata[key]);
    }
    return request.post('/user/login',params);
}

//获取用户详细信息
export const userInfoSer=()=>{
    return request.get('/user/userInfo')
}

//修改个人信息
export const userInfoUpdateSer=(userInfoData)=>{
    return request.put('/user/update', userInfoData)
}
 
//修改头像
export const userAvatarUpdateSer = (avatarUrl)=>{
    const params = new URLSearchParams();
    params.append('avatarUrl',avatarUrl)
    return request.patch('/user/updateAvatar',params)
}

//修改密码
export const userUpdatePasswordService = (pwdModel) => {
    const params = {
        old_pwd: pwdModel.oldpassword,
        new_pwd: pwdModel.newpassword,
        re_pwd: pwdModel.renewpassword
    };
    return request.patch('/user/updatePwd', params)
}
